<?php if(!defined("HDPHP_PATH"))exit;C("SHOW_NOTICE",FALSE);?><!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>商品编辑</title>
<script type='text/javascript' src='http://localhost/Git-SHOP/hdphp/hdphp/Extend/Org/Jquery/jquery-1.8.2.min.js'></script>
<link href='http://localhost/Git-SHOP/hdphp/hdphp/Extend/Org/hdjs/hdui/css/hdui.css' rel='stylesheet' media='screen'>
<script src='http://localhost/Git-SHOP/hdphp/hdphp/Extend/Org/hdjs/hdui/js/hdui.js'></script>
<link href='http://localhost/Git-SHOP/hdphp/hdphp/Extend/Org/hdjs/hdvalidate/css/hdvalidate.css' rel='stylesheet' media='screen'>
<script src='http://localhost/Git-SHOP/hdphp/hdphp/Extend/Org/hdjs/hdvalidate/js/hdvalidate.js'></script>
<script src='http://localhost/Git-SHOP/hdphp/hdphp/Extend/Org/cal/lhgcalendar.min.js'></script>
<script src='http://localhost/Git-SHOP/hdphp/hdphp/Extend/Org/hdjs/hdslide/js/hdslide.js'></script>
<script type='text/javascript'>
HOST = 'http://localhost';
ROOT = 'http://localhost/Git-SHOP';
WEB = 'http://localhost/Git-SHOP/index.php';
URL = 'http://localhost/Git-SHOP/index.php/Admin/Goods/edit/gid/23';
APP = 'http://localhost/Git-SHOP/HSHOP';
COMMON = 'http://localhost/Git-SHOP/HSHOP/Common';
HDPHP = 'http://localhost/Git-SHOP/hdphp/hdphp';
HDPHPDATA = 'http://localhost/Git-SHOP/hdphp/hdphp/Data';
HDPHPEXTEND = 'http://localhost/Git-SHOP/hdphp/hdphp/Extend';
MODULE = 'http://localhost/Git-SHOP/index.php/Admin';
CONTROLLER = 'http://localhost/Git-SHOP/index.php/Admin/Goods';
ACTION = 'http://localhost/Git-SHOP/index.php/Admin/Goods/edit';
STATIC = 'http://localhost/Git-SHOP/Static';
HDPHPTPL = 'http://localhost/Git-SHOP/hdphp/hdphp/Lib/Tpl';
VIEW = 'http://localhost/Git-SHOP/HSHOP/Admin/View';
PUBLIC = 'http://localhost/Git-SHOP/HSHOP/Admin/View/Public';
CONTROLLERVIEW = 'http://localhost/Git-SHOP/HSHOP/Admin/View/Goods';
HISTORY = 'http://localhost/Git-SHOP/index.php/Admin/Goods/index/page/4';
</script>
<script>
    //传商品id给异步处理
    var goods_gid="<?php echo $field['gid'];?>";
</script>
<script type="text/javascript" src="http://localhost/Git-SHOP/HSHOP/Admin/View/Goods/Js/addEdit.js"></script>

<!--编辑时 商品有商品类型时，自动获得商品属性-->
<?php if($field['goods_type']){?>
    <script>
        $(function(){
            $("[name='goods_type']").val("<?php echo $field['goods_type'];?>").change();
        })
    </script>
<?php }?>
</head>
<body>
<form action="" method="post" enctype='multipart/form-data'>
<input type="hidden" name="gid" value="<?php echo $field['gid'];?>">
	<div class="tab">
		<ul class="tab_menu">
			<li lab='base'>
			<a >基本选项</a>	
			</li>
			<li lab='other' class="action">
			<a >其他</a>	
			</li>
			<li lab='content'>
			<a >详情</a>	
			</li>
			<li lab='image'>
			<a >图片列表</a>	
			</li>
			<li lab='attribute'>
			<a >商品属性</a>	
			</li>
		</ul>
		<div class="tab_content hd-form">
			<div id="base">
				<table class="table1">
					<tr>
						<th class="W100">商品名称</th>
						<td>
							<input type="text" name="goods_name" class="w200" value="<?php echo $field['goods_name'];?>">
						</td>
					</tr>
					<tr>
						<th>栏目</th>
						<td>
							<select name="category_cid">
								<option value="0">==请选择栏目==</option>
								<?php $hd["list"]["c"]["total"]=0;if(isset($category) && !empty($category)):$_id_c=0;$_index_c=0;$lastc=min(1000,count($category));
$hd["list"]["c"]["first"]=true;
$hd["list"]["c"]["last"]=false;
$_total_c=ceil($lastc/1);$hd["list"]["c"]["total"]=$_total_c;
$_data_c = array_slice($category,0,$lastc);
if(count($_data_c)==0):echo "";
else:
foreach($_data_c as $key=>$c):
if(($_id_c)%1==0):$_id_c++;else:$_id_c++;continue;endif;
$hd["list"]["c"]["index"]=++$_index_c;
if($_index_c>=$_total_c):$hd["list"]["c"]["last"]=true;endif;?>

								<option value="<?php echo $c['cid'];?>"  <?php if($field['category_cid'] == $c['cid']){?>selected=""<?php }?>><?php echo $c['_name'];?> </option>
								<?php $hd["list"]["c"]["first"]=false;
endforeach;
endif;
else:
echo "";
endif;?>
							</select>
						</td>
					</tr>
					<tr>
						<th>商品货号</th>
						<td>
						<input type="text" name="goods_sn" class="w200" value="<?php echo $field['goods_sn'];?>">	
						</td>
					</tr>
					<tr>
						<th>属性</th>
						<td>
							<label>
								<input type="checkbox" name="is_hot" value="1" <?php if($field['is_hot'] ==1){?>checked=""<?php }?>>
								热门
							</label>
							<label>
								<input type="checkbox" name="is_new" value="1" <?php if($field['is_new'] ==1){?>checked=""<?php }?>>
								新品
							</label>
							<label>
								<input type="checkbox" name="is_best" value="1" <?php if($field['is_best'] ==1){?>checked=""<?php }?>>
								精品
							</label>	
						</td>
							
					</tr>
					<tr>
						<th>图片</th>
						<td>
							<input type="file" name="original_img" >
							<?php if($field['original_img']){?>
								<img src="http://localhost/Git-SHOP/<?php echo $field['original_img'];?>" alt="商品首页图片" width="100">
							<?php }?>
						</td>
					</tr>
					<tr>
						<th>是否上架</th>
						<td>
							<label >
								<input type="radio" name="is_on_sale" value="0" <?php if($field['is_on_sale'] ==0){?>checked=""<?php }?>>下架
							</label>
							<label >
								<input type="radio" name="is_on_sale" value="1" <?php if($field['is_on_sale'] ==1){?>checked=""<?php }?>>上架
							</label>
						</td>
					</tr>
					<tr>
						<th>市场价</th>
						<td>
						<input type="text" name="market_price" class='w200' value="<?php echo $field['market_price'];?>" /></td>
					</tr>
					<tr>
            			<th>商城价格</th>
           				<td>
            				<input type="text" name="goods_price" class='w200' value="<?php echo $field['goods_price'];?>"/>
            			</td>
        		  </tr>
				</table>
			</div>
			<div id="other">
				<table class="table1">
					<tr>
						<th class="w100">单位</th>
						<td>						
							<select name="goods_Company">
				               <option value="件" <?php if($field['goods_Company'] ==件){?>selected=""<?php }?>>件</option>
				               <option value="双" <?php if($field['goods_Company'] ==双){?>selected=""<?php }?>>双</option> 
             				 </select>
						</td>
					</tr>
					<tr>
						<th class="w100">上架时间</th>
						<td><!-- 把时间戳时间转为现在时间 -->
							<input type="text" readonly="readonly" id="sale_time" name="sale_time" value="<?php echo date('Y/m/d H:i:s',$field['sale_time']);?>" class="w150"/>
					<script>
						$('#sale_time').calendar({format: 'yyyy/MM/dd HH:mm:ss'});
					 </script>
						</td>
					</tr>
					<tr>
						<th>品牌</th>
						<td>
							<select name="brand_bid" class='w100'>
							<?php $hd["list"]["b"]["total"]=0;if(isset($brand) && !empty($brand)):$_id_b=0;$_index_b=0;$lastb=min(1000,count($brand));
$hd["list"]["b"]["first"]=true;
$hd["list"]["b"]["last"]=false;
$_total_b=ceil($lastb/1);$hd["list"]["b"]["total"]=$_total_b;
$_data_b = array_slice($brand,0,$lastb);
if(count($_data_b)==0):echo "";
else:
foreach($_data_b as $key=>$b):
if(($_id_b)%1==0):$_id_b++;else:$_id_b++;continue;endif;
$hd["list"]["b"]["index"]=++$_index_b;
if($_index_b>=$_total_b):$hd["list"]["b"]["last"]=true;endif;?>

								<option value="<?php echo $b['bid'];?>" <?php if($field['brand_bid'] == $b['bid']){?>selected=""<?php }?>><?php echo $b['brand_name'];?></option>
								<?php $hd["list"]["b"]["first"]=false;
endforeach;
endif;
else:
echo "";
endif;?>
							</select>
						</td>
					</tr>
					<tr>
						<th>商品数量</th>
						<td><input type="text" name="goods_number" class="w200" value="<?php echo $field['goods_number'];?>"></td>
					</tr>
					<tr>
						<th>查看</th>
						<td>
							<input type="text" name="goods_click" class="w200" value="<?php echo $field['goods_click'];?>">次
						</td>
					</tr>
				</table>
			</div>
			<div id="content">
				<table class="table1">
					<tr>
						<th class="w100">关键字</th>
						<td>
							<input type="text" name="goods_key" class="w200" value="<?php echo $goods_data['goods_key'];?>">
						</td>
					</tr>
					<tr>
						<th>描述</th>
						<td>
							<textarea name="goods_desc" class="w200 h100"><?php echo $goods_data['goods_desc'];?></textarea>
						</td>
					</tr>
					<tr>
						<th>详情</th>
						<td>
						<!-- 编辑器里面的用content不用value -->
							<script type="text/javascript" charset="utf-8" src="http://localhost/Git-SHOP/hdphp/hdphp/Extend/Org/Ueditor/ueditor.config.js"></script><script type="text/javascript" charset="utf-8" src="http://localhost/Git-SHOP/hdphp/hdphp/Extend/Org/Ueditor/ueditor.all.min.js"></script><script type="text/javascript">UEDITOR_HOME_URL="http://localhost/Git-SHOP/hdphp/hdphp/Extend/Org/Ueditor/"</script><script id="hd_goods_body" name="goods_body" type="text/plain"><?php echo $goods_data['goods_body'];?></script>
        <script type='text/javascript'>
        $(function(){
                var ue = UE.getEditor('hd_goods_body',{
                serverUrl:'http://localhost/Git-SHOP/index.php?m=Admin&c=Goods&gid=23&a=ueditor_upload&water='//图片上传脚本
                ,zIndex : 1000
                ,initialFrameWidth:"100%" //宽度1000
                ,catchRemoteImageEnable:false//关闭远程图片自动保存到本地
                ,initialFrameHeight:"300" //宽度1000
                ,imagePath:''//图片修正地址
                ,autoHeightEnabled:false //是否自动长高,默认true
                ,autoFloatEnabled:false //是否保持toolbar的位置不动,默认true
                ,toolbars:[
            ['fullscreen', 'source', '|', 'undo', 'redo', '|',
            'bold', 'italic', 'underline', 'fontborder', 'strikethrough', 'removeformat', 'formatmatch', 'autotypeset',
            '|', 'forecolor', 'backcolor', 'insertorderedlist', 'insertunorderedlist', '|',
            'lineheight', '|','paragraph', 'fontfamily', 'fontsize', '|',
             'indent','justifyleft', 'justifycenter', 'justifyright', 'justifyjustify', '|',
            'link', 'unlink', '|', 'imagenone', 'imageleft', 'imageright', 'imagecenter', '|',
            'insertimage', 'emotion',   'map',  'insertcode',  'pagebreak','horizontal', '|',
            'inserttable', 'deletetable', 'insertparagraphbeforetable', 'insertrow',  'insertcol',  'mergecells', 'mergeright', 'mergedown', 'splittocells', 'splittorows', 'splittocols']
            ]//工具按钮
                ,enableAutoSave: false//关闭自动保存
                ,initialStyle:'p{line-height:1em; font-size: 14px; }'
            });
        })
        </script>
						</td>
					</tr>
				</table>
			</div>
			<div id='image'>
	        	<table class='table1'>
	        		<tr>
	        			<th class='w100'>图片列表</th>
	        			<td>
			                <div class="gallery">
		                    <ul>
		                        <?php $hd["list"]["g"]["total"]=0;if(isset($gallery) && !empty($gallery)):$_id_g=0;$_index_g=0;$lastg=min(1000,count($gallery));
$hd["list"]["g"]["first"]=true;
$hd["list"]["g"]["last"]=false;
$_total_g=ceil($lastg/1);$hd["list"]["g"]["total"]=$_total_g;
$_data_g = array_slice($gallery,0,$lastg);
if(count($_data_g)==0):echo "";
else:
foreach($_data_g as $key=>$g):
if(($_id_g)%1==0):$_id_g++;else:$_id_g++;continue;endif;
$hd["list"]["g"]["index"]=++$_index_g;
if($_index_g>=$_total_g):$hd["list"]["g"]["last"]=true;endif;?>

	                            <li style="float:left;margin:10px;">
	                                <img src="http://localhost/Git-SHOP/<?php echo $g['img_original'];?>" width="100" height='80' alt="详情页图片"/>
	                                <a href="javascript:;" onclick="delGalleryImage(this,<?php echo $g['goods_gallery_id'];?>);">X</a>
	                            </li>
		                        <?php $hd["list"]["g"]["first"]=false;
endforeach;
endif;
else:
echo "";
endif;?>
		                    </ul>
			                </div>
	        				<ul id="imageList" style="clear: both">
        					<li>
    						<a href="javascript:addImage()">[+]</a>
    						<input type="file" name='gallery_img[]' class='w100'>
        					</li>
	        				</ul>
	        			</td>
	        		</tr>
        		</table>       		
        	</div>
<!-- 商品属性	 -->
		<div id='attribute'>
        	<table class='table1'>
        		<tr>
        			<th class='w100'>商品类型</th>
        			<td>
        				<select name="goods_type" id="goods_type" onchange="getAttr();">
                            <option value="">==选择类型==</option>
        					<?php $hd["list"]["gt"]["total"]=0;if(isset($goods_type) && !empty($goods_type)):$_id_gt=0;$_index_gt=0;$lastgt=min(1000,count($goods_type));
$hd["list"]["gt"]["first"]=true;
$hd["list"]["gt"]["last"]=false;
$_total_gt=ceil($lastgt/1);$hd["list"]["gt"]["total"]=$_total_gt;
$_data_gt = array_slice($goods_type,0,$lastgt);
if(count($_data_gt)==0):echo "";
else:
foreach($_data_gt as $key=>$gt):
if(($_id_gt)%1==0):$_id_gt++;else:$_id_gt++;continue;endif;
$hd["list"]["gt"]["index"]=++$_index_gt;
if($_index_gt>=$_total_gt):$hd["list"]["gt"]["last"]=true;endif;?>

							<option value="<?php echo $gt['cat_id'];?>"><?php echo $gt['cat_name'];?></option>
        					<?php $hd["list"]["gt"]["first"]=false;
endforeach;
endif;
else:
echo "";
endif;?>
        				</select>
        			</td>
        		</tr>
            <tr>
              <th>属性</th>
              <td>
                 <div id="attr">

                </div>
              </td>
            </tr>
        	</table>
        </div>
    </div>
</div>
<input type="submit" value='编辑' class='hd-success'>
</form>
</body>
</html>